// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Code generated by sidekick. DO NOT EDIT.

use crate::Result;
#[allow(unused_imports)]
use gax::error::Error;

const DEFAULT_HOST: &str = "https://storage.googleapis.com";

mod info {
    const NAME: &str = env!("CARGO_PKG_NAME");
    const VERSION: &str = env!("CARGO_PKG_VERSION");
    lazy_static::lazy_static! {
        pub(crate) static ref X_GOOG_API_CLIENT_HEADER: String = {
            let ac = gaxi::api_header::XGoogApiClient{
                name:          NAME,
                version:       VERSION,
                library_type:  gaxi::api_header::GAPIC,
            };
            ac.grpc_header_value()
        };
    }
}

/// Implements [StorageControl](super::stub::StorageControl) using a Tonic-generated client.
#[derive(Clone)]
pub struct StorageControl {
    inner: gaxi::grpc::Client,
}

impl std::fmt::Debug for StorageControl {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
        f.debug_struct("StorageControl")
            .field("inner", &self.inner)
            .finish()
    }
}

impl StorageControl {
    pub async fn new(config: gaxi::options::ClientConfig) -> gax::client_builder::Result<Self> {
        let inner = gaxi::grpc::Client::new(config, DEFAULT_HOST).await?;
        Ok(Self { inner })
    }
}

impl super::stub::StorageControl for StorageControl {
    async fn create_folder(
        &self,
        req: crate::model::CreateFolderRequest,
        options: gax::options::RequestOptions,
    ) -> Result<gax::response::Response<crate::model::Folder>> {
        use gaxi::prost::ToProto;
        let options = gax::options::internal::set_default_idempotency(options, true);
        let extensions = {
            let mut e = tonic::Extensions::new();
            e.insert(tonic::GrpcMethod::new(
                "google.storage.control.v2.StorageControl",
                "CreateFolder",
            ));
            e
        };
        let path = http::uri::PathAndQuery::from_static(
            "/google.storage.control.v2.StorageControl/CreateFolder",
        );
        let x_goog_request_params = {
            use gaxi::routing_parameter::Segment;
            gaxi::routing_parameter::format(&[None
                .or_else(|| {
                    gaxi::routing_parameter::value(
                        Some(&req).map(|m| &m.parent).map(|s| s.as_str()),
                        &[],
                        &[Segment::MultiWildcard],
                        &[],
                    )
                })
                .map(|v| ("bucket", v))])
        };
        if x_goog_request_params.is_empty() {
            use gax::error::binding::BindingError;
            use gaxi::path_parameter::PathMismatchBuilder;
            use gaxi::routing_parameter::Segment;
            let mut paths = Vec::new();
            {
                let builder = PathMismatchBuilder::default();
                let builder = builder.maybe_add(
                    Some(&req).map(|m| &m.parent).map(|s| s.as_str()),
                    &[Segment::MultiWildcard],
                    "parent",
                    "**",
                );
                paths.push(builder.build());
            }
            return Err(gax::error::Error::binding(BindingError { paths }));
        }

        type TR = crate::google::storage::control::v2::Folder;
        self.inner
            .execute(
                extensions,
                path,
                req.to_proto().map_err(Error::deser)?,
                options,
                &info::X_GOOG_API_CLIENT_HEADER,
                &x_goog_request_params,
            )
            .await
            .and_then(gaxi::grpc::to_gax_response::<TR, crate::model::Folder>)
    }

    async fn delete_folder(
        &self,
        req: crate::model::DeleteFolderRequest,
        options: gax::options::RequestOptions,
    ) -> Result<gax::response::Response<()>> {
        use gaxi::prost::ToProto;
        let options = gax::options::internal::set_default_idempotency(options, true);
        let extensions = {
            let mut e = tonic::Extensions::new();
            e.insert(tonic::GrpcMethod::new(
                "google.storage.control.v2.StorageControl",
                "DeleteFolder",
            ));
            e
        };
        let path = http::uri::PathAndQuery::from_static(
            "/google.storage.control.v2.StorageControl/DeleteFolder",
        );
        let x_goog_request_params = {
            use gaxi::routing_parameter::Segment;
            gaxi::routing_parameter::format(&[None
                .or_else(|| {
                    gaxi::routing_parameter::value(
                        Some(&req).map(|m| &m.name).map(|s| s.as_str()),
                        &[],
                        &[
                            Segment::Literal("projects/"),
                            Segment::SingleWildcard,
                            Segment::Literal("/buckets/"),
                            Segment::SingleWildcard,
                        ],
                        &[Segment::MultiWildcard],
                    )
                })
                .map(|v| ("bucket", v))])
        };
        if x_goog_request_params.is_empty() {
            use gax::error::binding::BindingError;
            use gaxi::path_parameter::PathMismatchBuilder;
            use gaxi::routing_parameter::Segment;
            let mut paths = Vec::new();
            {
                let builder = PathMismatchBuilder::default();
                let builder = builder.maybe_add(
                    Some(&req).map(|m| &m.name).map(|s| s.as_str()),
                    &[
                        Segment::Literal("projects/"),
                        Segment::SingleWildcard,
                        Segment::Literal("/buckets/"),
                        Segment::SingleWildcard,
                        Segment::MultiWildcard,
                    ],
                    "name",
                    "projects/*/buckets/*/**",
                );
                paths.push(builder.build());
            }
            return Err(gax::error::Error::binding(BindingError { paths }));
        }

        type TR = ();
        self.inner
            .execute(
                extensions,
                path,
                req.to_proto().map_err(Error::deser)?,
                options,
                &info::X_GOOG_API_CLIENT_HEADER,
                &x_goog_request_params,
            )
            .await
            .and_then(gaxi::grpc::to_gax_response::<TR, ()>)
    }

    async fn get_folder(
        &self,
        req: crate::model::GetFolderRequest,
        options: gax::options::RequestOptions,
    ) -> Result<gax::response::Response<crate::model::Folder>> {
        use gaxi::prost::ToProto;
        let options = gax::options::internal::set_default_idempotency(options, true);
        let extensions = {
            let mut e = tonic::Extensions::new();
            e.insert(tonic::GrpcMethod::new(
                "google.storage.control.v2.StorageControl",
                "GetFolder",
            ));
            e
        };
        let path = http::uri::PathAndQuery::from_static(
            "/google.storage.control.v2.StorageControl/GetFolder",
        );
        let x_goog_request_params = {
            use gaxi::routing_parameter::Segment;
            gaxi::routing_parameter::format(&[None
                .or_else(|| {
                    gaxi::routing_parameter::value(
                        Some(&req).map(|m| &m.name).map(|s| s.as_str()),
                        &[],
                        &[
                            Segment::Literal("projects/"),
                            Segment::SingleWildcard,
                            Segment::Literal("/buckets/"),
                            Segment::SingleWildcard,
                        ],
                        &[Segment::MultiWildcard],
                    )
                })
                .map(|v| ("bucket", v))])
        };
        if x_goog_request_params.is_empty() {
            use gax::error::binding::BindingError;
            use gaxi::path_parameter::PathMismatchBuilder;
            use gaxi::routing_parameter::Segment;
            let mut paths = Vec::new();
            {
                let builder = PathMismatchBuilder::default();
                let builder = builder.maybe_add(
                    Some(&req).map(|m| &m.name).map(|s| s.as_str()),
                    &[
                        Segment::Literal("projects/"),
                        Segment::SingleWildcard,
                        Segment::Literal("/buckets/"),
                        Segment::SingleWildcard,
                        Segment::MultiWildcard,
                    ],
                    "name",
                    "projects/*/buckets/*/**",
                );
                paths.push(builder.build());
            }
            return Err(gax::error::Error::binding(BindingError { paths }));
        }

        type TR = crate::google::storage::control::v2::Folder;
        self.inner
            .execute(
                extensions,
                path,
                req.to_proto().map_err(Error::deser)?,
                options,
                &info::X_GOOG_API_CLIENT_HEADER,
                &x_goog_request_params,
            )
            .await
            .and_then(gaxi::grpc::to_gax_response::<TR, crate::model::Folder>)
    }

    async fn list_folders(
        &self,
        req: crate::model::ListFoldersRequest,
        options: gax::options::RequestOptions,
    ) -> Result<gax::response::Response<crate::model::ListFoldersResponse>> {
        use gaxi::prost::ToProto;
        let options = gax::options::internal::set_default_idempotency(options, false);
        let extensions = {
            let mut e = tonic::Extensions::new();
            e.insert(tonic::GrpcMethod::new(
                "google.storage.control.v2.StorageControl",
                "ListFolders",
            ));
            e
        };
        let path = http::uri::PathAndQuery::from_static(
            "/google.storage.control.v2.StorageControl/ListFolders",
        );
        let x_goog_request_params = {
            use gaxi::routing_parameter::Segment;
            gaxi::routing_parameter::format(&[None
                .or_else(|| {
                    gaxi::routing_parameter::value(
                        Some(&req).map(|m| &m.parent).map(|s| s.as_str()),
                        &[],
                        &[Segment::MultiWildcard],
                        &[],
                    )
                })
                .map(|v| ("bucket", v))])
        };
        if x_goog_request_params.is_empty() {
            use gax::error::binding::BindingError;
            use gaxi::path_parameter::PathMismatchBuilder;
            use gaxi::routing_parameter::Segment;
            let mut paths = Vec::new();
            {
                let builder = PathMismatchBuilder::default();
                let builder = builder.maybe_add(
                    Some(&req).map(|m| &m.parent).map(|s| s.as_str()),
                    &[Segment::MultiWildcard],
                    "parent",
                    "**",
                );
                paths.push(builder.build());
            }
            return Err(gax::error::Error::binding(BindingError { paths }));
        }

        type TR = crate::google::storage::control::v2::ListFoldersResponse;
        self.inner
            .execute(
                extensions,
                path,
                req.to_proto().map_err(Error::deser)?,
                options,
                &info::X_GOOG_API_CLIENT_HEADER,
                &x_goog_request_params,
            )
            .await
            .and_then(gaxi::grpc::to_gax_response::<TR, crate::model::ListFoldersResponse>)
    }

    async fn rename_folder(
        &self,
        req: crate::model::RenameFolderRequest,
        options: gax::options::RequestOptions,
    ) -> Result<gax::response::Response<longrunning::model::Operation>> {
        use gaxi::prost::ToProto;
        let options = gax::options::internal::set_default_idempotency(options, true);
        let extensions = {
            let mut e = tonic::Extensions::new();
            e.insert(tonic::GrpcMethod::new(
                "google.storage.control.v2.StorageControl",
                "RenameFolder",
            ));
            e
        };
        let path = http::uri::PathAndQuery::from_static(
            "/google.storage.control.v2.StorageControl/RenameFolder",
        );
        let x_goog_request_params = {
            use gaxi::routing_parameter::Segment;
            gaxi::routing_parameter::format(&[None
                .or_else(|| {
                    gaxi::routing_parameter::value(
                        Some(&req).map(|m| &m.name).map(|s| s.as_str()),
                        &[],
                        &[
                            Segment::Literal("projects/"),
                            Segment::SingleWildcard,
                            Segment::Literal("/buckets/"),
                            Segment::SingleWildcard,
                        ],
                        &[Segment::MultiWildcard],
                    )
                })
                .map(|v| ("bucket", v))])
        };
        if x_goog_request_params.is_empty() {
            use gax::error::binding::BindingError;
            use gaxi::path_parameter::PathMismatchBuilder;
            use gaxi::routing_parameter::Segment;
            let mut paths = Vec::new();
            {
                let builder = PathMismatchBuilder::default();
                let builder = builder.maybe_add(
                    Some(&req).map(|m| &m.name).map(|s| s.as_str()),
                    &[
                        Segment::Literal("projects/"),
                        Segment::SingleWildcard,
                        Segment::Literal("/buckets/"),
                        Segment::SingleWildcard,
                        Segment::MultiWildcard,
                    ],
                    "name",
                    "projects/*/buckets/*/**",
                );
                paths.push(builder.build());
            }
            return Err(gax::error::Error::binding(BindingError { paths }));
        }

        type TR = crate::google::longrunning::Operation;
        self.inner
            .execute(
                extensions,
                path,
                req.to_proto().map_err(Error::deser)?,
                options,
                &info::X_GOOG_API_CLIENT_HEADER,
                &x_goog_request_params,
            )
            .await
            .and_then(gaxi::grpc::to_gax_response::<TR, longrunning::model::Operation>)
    }

    async fn get_storage_layout(
        &self,
        req: crate::model::GetStorageLayoutRequest,
        options: gax::options::RequestOptions,
    ) -> Result<gax::response::Response<crate::model::StorageLayout>> {
        use gaxi::prost::ToProto;
        let options = gax::options::internal::set_default_idempotency(options, true);
        let extensions = {
            let mut e = tonic::Extensions::new();
            e.insert(tonic::GrpcMethod::new(
                "google.storage.control.v2.StorageControl",
                "GetStorageLayout",
            ));
            e
        };
        let path = http::uri::PathAndQuery::from_static(
            "/google.storage.control.v2.StorageControl/GetStorageLayout",
        );
        let x_goog_request_params = {
            use gaxi::routing_parameter::Segment;
            gaxi::routing_parameter::format(&[None
                .or_else(|| {
                    gaxi::routing_parameter::value(
                        Some(&req).map(|m| &m.name).map(|s| s.as_str()),
                        &[],
                        &[
                            Segment::Literal("projects/"),
                            Segment::SingleWildcard,
                            Segment::Literal("/buckets/"),
                            Segment::SingleWildcard,
                        ],
                        &[Segment::MultiWildcard],
                    )
                })
                .map(|v| ("bucket", v))])
        };
        if x_goog_request_params.is_empty() {
            use gax::error::binding::BindingError;
            use gaxi::path_parameter::PathMismatchBuilder;
            use gaxi::routing_parameter::Segment;
            let mut paths = Vec::new();
            {
                let builder = PathMismatchBuilder::default();
                let builder = builder.maybe_add(
                    Some(&req).map(|m| &m.name).map(|s| s.as_str()),
                    &[
                        Segment::Literal("projects/"),
                        Segment::SingleWildcard,
                        Segment::Literal("/buckets/"),
                        Segment::SingleWildcard,
                        Segment::MultiWildcard,
                    ],
                    "name",
                    "projects/*/buckets/*/**",
                );
                paths.push(builder.build());
            }
            return Err(gax::error::Error::binding(BindingError { paths }));
        }

        type TR = crate::google::storage::control::v2::StorageLayout;
        self.inner
            .execute(
                extensions,
                path,
                req.to_proto().map_err(Error::deser)?,
                options,
                &info::X_GOOG_API_CLIENT_HEADER,
                &x_goog_request_params,
            )
            .await
            .and_then(gaxi::grpc::to_gax_response::<TR, crate::model::StorageLayout>)
    }

    async fn create_managed_folder(
        &self,
        req: crate::model::CreateManagedFolderRequest,
        options: gax::options::RequestOptions,
    ) -> Result<gax::response::Response<crate::model::ManagedFolder>> {
        use gaxi::prost::ToProto;
        let options = gax::options::internal::set_default_idempotency(options, true);
        let extensions = {
            let mut e = tonic::Extensions::new();
            e.insert(tonic::GrpcMethod::new(
                "google.storage.control.v2.StorageControl",
                "CreateManagedFolder",
            ));
            e
        };
        let path = http::uri::PathAndQuery::from_static(
            "/google.storage.control.v2.StorageControl/CreateManagedFolder",
        );
        let x_goog_request_params = {
            use gaxi::routing_parameter::Segment;
            gaxi::routing_parameter::format(&[None
                .or_else(|| {
                    gaxi::routing_parameter::value(
                        Some(&req).map(|m| &m.parent).map(|s| s.as_str()),
                        &[],
                        &[Segment::MultiWildcard],
                        &[],
                    )
                })
                .map(|v| ("bucket", v))])
        };
        if x_goog_request_params.is_empty() {
            use gax::error::binding::BindingError;
            use gaxi::path_parameter::PathMismatchBuilder;
            use gaxi::routing_parameter::Segment;
            let mut paths = Vec::new();
            {
                let builder = PathMismatchBuilder::default();
                let builder = builder.maybe_add(
                    Some(&req).map(|m| &m.parent).map(|s| s.as_str()),
                    &[Segment::MultiWildcard],
                    "parent",
                    "**",
                );
                paths.push(builder.build());
            }
            return Err(gax::error::Error::binding(BindingError { paths }));
        }

        type TR = crate::google::storage::control::v2::ManagedFolder;
        self.inner
            .execute(
                extensions,
                path,
                req.to_proto().map_err(Error::deser)?,
                options,
                &info::X_GOOG_API_CLIENT_HEADER,
                &x_goog_request_params,
            )
            .await
            .and_then(gaxi::grpc::to_gax_response::<TR, crate::model::ManagedFolder>)
    }

    async fn delete_managed_folder(
        &self,
        req: crate::model::DeleteManagedFolderRequest,
        options: gax::options::RequestOptions,
    ) -> Result<gax::response::Response<()>> {
        use gaxi::prost::ToProto;
        let options = gax::options::internal::set_default_idempotency(options, true);
        let extensions = {
            let mut e = tonic::Extensions::new();
            e.insert(tonic::GrpcMethod::new(
                "google.storage.control.v2.StorageControl",
                "DeleteManagedFolder",
            ));
            e
        };
        let path = http::uri::PathAndQuery::from_static(
            "/google.storage.control.v2.StorageControl/DeleteManagedFolder",
        );
        let x_goog_request_params = {
            use gaxi::routing_parameter::Segment;
            gaxi::routing_parameter::format(&[None
                .or_else(|| {
                    gaxi::routing_parameter::value(
                        Some(&req).map(|m| &m.name).map(|s| s.as_str()),
                        &[],
                        &[
                            Segment::Literal("projects/"),
                            Segment::SingleWildcard,
                            Segment::Literal("/buckets/"),
                            Segment::SingleWildcard,
                        ],
                        &[Segment::MultiWildcard],
                    )
                })
                .map(|v| ("bucket", v))])
        };
        if x_goog_request_params.is_empty() {
            use gax::error::binding::BindingError;
            use gaxi::path_parameter::PathMismatchBuilder;
            use gaxi::routing_parameter::Segment;
            let mut paths = Vec::new();
            {
                let builder = PathMismatchBuilder::default();
                let builder = builder.maybe_add(
                    Some(&req).map(|m| &m.name).map(|s| s.as_str()),
                    &[
                        Segment::Literal("projects/"),
                        Segment::SingleWildcard,
                        Segment::Literal("/buckets/"),
                        Segment::SingleWildcard,
                        Segment::MultiWildcard,
                    ],
                    "name",
                    "projects/*/buckets/*/**",
                );
                paths.push(builder.build());
            }
            return Err(gax::error::Error::binding(BindingError { paths }));
        }

        type TR = ();
        self.inner
            .execute(
                extensions,
                path,
                req.to_proto().map_err(Error::deser)?,
                options,
                &info::X_GOOG_API_CLIENT_HEADER,
                &x_goog_request_params,
            )
            .await
            .and_then(gaxi::grpc::to_gax_response::<TR, ()>)
    }

    async fn get_managed_folder(
        &self,
        req: crate::model::GetManagedFolderRequest,
        options: gax::options::RequestOptions,
    ) -> Result<gax::response::Response<crate::model::ManagedFolder>> {
        use gaxi::prost::ToProto;
        let options = gax::options::internal::set_default_idempotency(options, true);
        let extensions = {
            let mut e = tonic::Extensions::new();
            e.insert(tonic::GrpcMethod::new(
                "google.storage.control.v2.StorageControl",
                "GetManagedFolder",
            ));
            e
        };
        let path = http::uri::PathAndQuery::from_static(
            "/google.storage.control.v2.StorageControl/GetManagedFolder",
        );
        let x_goog_request_params = {
            use gaxi::routing_parameter::Segment;
            gaxi::routing_parameter::format(&[None
                .or_else(|| {
                    gaxi::routing_parameter::value(
                        Some(&req).map(|m| &m.name).map(|s| s.as_str()),
                        &[],
                        &[
                            Segment::Literal("projects/"),
                            Segment::SingleWildcard,
                            Segment::Literal("/buckets/"),
                            Segment::SingleWildcard,
                        ],
                        &[Segment::MultiWildcard],
                    )
                })
                .map(|v| ("bucket", v))])
        };
        if x_goog_request_params.is_empty() {
            use gax::error::binding::BindingError;
            use gaxi::path_parameter::PathMismatchBuilder;
            use gaxi::routing_parameter::Segment;
            let mut paths = Vec::new();
            {
                let builder = PathMismatchBuilder::default();
                let builder = builder.maybe_add(
                    Some(&req).map(|m| &m.name).map(|s| s.as_str()),
                    &[
                        Segment::Literal("projects/"),
                        Segment::SingleWildcard,
                        Segment::Literal("/buckets/"),
                        Segment::SingleWildcard,
                        Segment::MultiWildcard,
                    ],
                    "name",
                    "projects/*/buckets/*/**",
                );
                paths.push(builder.build());
            }
            return Err(gax::error::Error::binding(BindingError { paths }));
        }

        type TR = crate::google::storage::control::v2::ManagedFolder;
        self.inner
            .execute(
                extensions,
                path,
                req.to_proto().map_err(Error::deser)?,
                options,
                &info::X_GOOG_API_CLIENT_HEADER,
                &x_goog_request_params,
            )
            .await
            .and_then(gaxi::grpc::to_gax_response::<TR, crate::model::ManagedFolder>)
    }

    async fn list_managed_folders(
        &self,
        req: crate::model::ListManagedFoldersRequest,
        options: gax::options::RequestOptions,
    ) -> Result<gax::response::Response<crate::model::ListManagedFoldersResponse>> {
        use gaxi::prost::ToProto;
        let options = gax::options::internal::set_default_idempotency(options, true);
        let extensions = {
            let mut e = tonic::Extensions::new();
            e.insert(tonic::GrpcMethod::new(
                "google.storage.control.v2.StorageControl",
                "ListManagedFolders",
            ));
            e
        };
        let path = http::uri::PathAndQuery::from_static(
            "/google.storage.control.v2.StorageControl/ListManagedFolders",
        );
        let x_goog_request_params = {
            use gaxi::routing_parameter::Segment;
            gaxi::routing_parameter::format(&[None
                .or_else(|| {
                    gaxi::routing_parameter::value(
                        Some(&req).map(|m| &m.parent).map(|s| s.as_str()),
                        &[],
                        &[Segment::MultiWildcard],
                        &[],
                    )
                })
                .map(|v| ("bucket", v))])
        };
        if x_goog_request_params.is_empty() {
            use gax::error::binding::BindingError;
            use gaxi::path_parameter::PathMismatchBuilder;
            use gaxi::routing_parameter::Segment;
            let mut paths = Vec::new();
            {
                let builder = PathMismatchBuilder::default();
                let builder = builder.maybe_add(
                    Some(&req).map(|m| &m.parent).map(|s| s.as_str()),
                    &[Segment::MultiWildcard],
                    "parent",
                    "**",
                );
                paths.push(builder.build());
            }
            return Err(gax::error::Error::binding(BindingError { paths }));
        }

        type TR = crate::google::storage::control::v2::ListManagedFoldersResponse;
        self.inner
            .execute(
                extensions,
                path,
                req.to_proto().map_err(Error::deser)?,
                options,
                &info::X_GOOG_API_CLIENT_HEADER,
                &x_goog_request_params,
            )
            .await
            .and_then(gaxi::grpc::to_gax_response::<TR, crate::model::ListManagedFoldersResponse>)
    }

    async fn create_anywhere_cache(
        &self,
        req: crate::model::CreateAnywhereCacheRequest,
        options: gax::options::RequestOptions,
    ) -> Result<gax::response::Response<longrunning::model::Operation>> {
        use gaxi::prost::ToProto;
        let options = gax::options::internal::set_default_idempotency(options, true);
        let extensions = {
            let mut e = tonic::Extensions::new();
            e.insert(tonic::GrpcMethod::new(
                "google.storage.control.v2.StorageControl",
                "CreateAnywhereCache",
            ));
            e
        };
        let path = http::uri::PathAndQuery::from_static(
            "/google.storage.control.v2.StorageControl/CreateAnywhereCache",
        );
        let x_goog_request_params = {
            use gaxi::routing_parameter::Segment;
            gaxi::routing_parameter::format(&[None
                .or_else(|| {
                    gaxi::routing_parameter::value(
                        Some(&req).map(|m| &m.parent).map(|s| s.as_str()),
                        &[],
                        &[Segment::MultiWildcard],
                        &[],
                    )
                })
                .map(|v| ("bucket", v))])
        };
        if x_goog_request_params.is_empty() {
            use gax::error::binding::BindingError;
            use gaxi::path_parameter::PathMismatchBuilder;
            use gaxi::routing_parameter::Segment;
            let mut paths = Vec::new();
            {
                let builder = PathMismatchBuilder::default();
                let builder = builder.maybe_add(
                    Some(&req).map(|m| &m.parent).map(|s| s.as_str()),
                    &[Segment::MultiWildcard],
                    "parent",
                    "**",
                );
                paths.push(builder.build());
            }
            return Err(gax::error::Error::binding(BindingError { paths }));
        }

        type TR = crate::google::longrunning::Operation;
        self.inner
            .execute(
                extensions,
                path,
                req.to_proto().map_err(Error::deser)?,
                options,
                &info::X_GOOG_API_CLIENT_HEADER,
                &x_goog_request_params,
            )
            .await
            .and_then(gaxi::grpc::to_gax_response::<TR, longrunning::model::Operation>)
    }

    async fn update_anywhere_cache(
        &self,
        req: crate::model::UpdateAnywhereCacheRequest,
        options: gax::options::RequestOptions,
    ) -> Result<gax::response::Response<longrunning::model::Operation>> {
        use gaxi::prost::ToProto;
        let options = gax::options::internal::set_default_idempotency(options, true);
        let extensions = {
            let mut e = tonic::Extensions::new();
            e.insert(tonic::GrpcMethod::new(
                "google.storage.control.v2.StorageControl",
                "UpdateAnywhereCache",
            ));
            e
        };
        let path = http::uri::PathAndQuery::from_static(
            "/google.storage.control.v2.StorageControl/UpdateAnywhereCache",
        );
        let x_goog_request_params = {
            use gaxi::routing_parameter::Segment;
            gaxi::routing_parameter::format(&[None
                .or_else(|| {
                    gaxi::routing_parameter::value(
                        Some(&req)
                            .and_then(|m| m.anywhere_cache.as_ref())
                            .map(|m| &m.name)
                            .map(|s| s.as_str()),
                        &[],
                        &[
                            Segment::Literal("projects/"),
                            Segment::SingleWildcard,
                            Segment::Literal("/buckets/"),
                            Segment::SingleWildcard,
                        ],
                        &[Segment::MultiWildcard],
                    )
                })
                .map(|v| ("bucket", v))])
        };
        if x_goog_request_params.is_empty() {
            use gax::error::binding::BindingError;
            use gaxi::path_parameter::PathMismatchBuilder;
            use gaxi::routing_parameter::Segment;
            let mut paths = Vec::new();
            {
                let builder = PathMismatchBuilder::default();
                let builder = builder.maybe_add(
                    Some(&req)
                        .and_then(|m| m.anywhere_cache.as_ref())
                        .map(|m| &m.name)
                        .map(|s| s.as_str()),
                    &[
                        Segment::Literal("projects/"),
                        Segment::SingleWildcard,
                        Segment::Literal("/buckets/"),
                        Segment::SingleWildcard,
                        Segment::MultiWildcard,
                    ],
                    "anywhere_cache.name",
                    "projects/*/buckets/*/**",
                );
                paths.push(builder.build());
            }
            return Err(gax::error::Error::binding(BindingError { paths }));
        }

        type TR = crate::google::longrunning::Operation;
        self.inner
            .execute(
                extensions,
                path,
                req.to_proto().map_err(Error::deser)?,
                options,
                &info::X_GOOG_API_CLIENT_HEADER,
                &x_goog_request_params,
            )
            .await
            .and_then(gaxi::grpc::to_gax_response::<TR, longrunning::model::Operation>)
    }

    async fn disable_anywhere_cache(
        &self,
        req: crate::model::DisableAnywhereCacheRequest,
        options: gax::options::RequestOptions,
    ) -> Result<gax::response::Response<crate::model::AnywhereCache>> {
        use gaxi::prost::ToProto;
        let options = gax::options::internal::set_default_idempotency(options, true);
        let extensions = {
            let mut e = tonic::Extensions::new();
            e.insert(tonic::GrpcMethod::new(
                "google.storage.control.v2.StorageControl",
                "DisableAnywhereCache",
            ));
            e
        };
        let path = http::uri::PathAndQuery::from_static(
            "/google.storage.control.v2.StorageControl/DisableAnywhereCache",
        );
        let x_goog_request_params = {
            use gaxi::routing_parameter::Segment;
            gaxi::routing_parameter::format(&[None
                .or_else(|| {
                    gaxi::routing_parameter::value(
                        Some(&req).map(|m| &m.name).map(|s| s.as_str()),
                        &[],
                        &[
                            Segment::Literal("projects/"),
                            Segment::SingleWildcard,
                            Segment::Literal("/buckets/"),
                            Segment::SingleWildcard,
                        ],
                        &[Segment::MultiWildcard],
                    )
                })
                .map(|v| ("bucket", v))])
        };
        if x_goog_request_params.is_empty() {
            use gax::error::binding::BindingError;
            use gaxi::path_parameter::PathMismatchBuilder;
            use gaxi::routing_parameter::Segment;
            let mut paths = Vec::new();
            {
                let builder = PathMismatchBuilder::default();
                let builder = builder.maybe_add(
                    Some(&req).map(|m| &m.name).map(|s| s.as_str()),
                    &[
                        Segment::Literal("projects/"),
                        Segment::SingleWildcard,
                        Segment::Literal("/buckets/"),
                        Segment::SingleWildcard,
                        Segment::MultiWildcard,
                    ],
                    "name",
                    "projects/*/buckets/*/**",
                );
                paths.push(builder.build());
            }
            return Err(gax::error::Error::binding(BindingError { paths }));
        }

        type TR = crate::google::storage::control::v2::AnywhereCache;
        self.inner
            .execute(
                extensions,
                path,
                req.to_proto().map_err(Error::deser)?,
                options,
                &info::X_GOOG_API_CLIENT_HEADER,
                &x_goog_request_params,
            )
            .await
            .and_then(gaxi::grpc::to_gax_response::<TR, crate::model::AnywhereCache>)
    }

    async fn pause_anywhere_cache(
        &self,
        req: crate::model::PauseAnywhereCacheRequest,
        options: gax::options::RequestOptions,
    ) -> Result<gax::response::Response<crate::model::AnywhereCache>> {
        use gaxi::prost::ToProto;
        let options = gax::options::internal::set_default_idempotency(options, true);
        let extensions = {
            let mut e = tonic::Extensions::new();
            e.insert(tonic::GrpcMethod::new(
                "google.storage.control.v2.StorageControl",
                "PauseAnywhereCache",
            ));
            e
        };
        let path = http::uri::PathAndQuery::from_static(
            "/google.storage.control.v2.StorageControl/PauseAnywhereCache",
        );
        let x_goog_request_params = {
            use gaxi::routing_parameter::Segment;
            gaxi::routing_parameter::format(&[None
                .or_else(|| {
                    gaxi::routing_parameter::value(
                        Some(&req).map(|m| &m.name).map(|s| s.as_str()),
                        &[],
                        &[
                            Segment::Literal("projects/"),
                            Segment::SingleWildcard,
                            Segment::Literal("/buckets/"),
                            Segment::SingleWildcard,
                        ],
                        &[Segment::MultiWildcard],
                    )
                })
                .map(|v| ("bucket", v))])
        };
        if x_goog_request_params.is_empty() {
            use gax::error::binding::BindingError;
            use gaxi::path_parameter::PathMismatchBuilder;
            use gaxi::routing_parameter::Segment;
            let mut paths = Vec::new();
            {
                let builder = PathMismatchBuilder::default();
                let builder = builder.maybe_add(
                    Some(&req).map(|m| &m.name).map(|s| s.as_str()),
                    &[
                        Segment::Literal("projects/"),
                        Segment::SingleWildcard,
                        Segment::Literal("/buckets/"),
                        Segment::SingleWildcard,
                        Segment::MultiWildcard,
                    ],
                    "name",
                    "projects/*/buckets/*/**",
                );
                paths.push(builder.build());
            }
            return Err(gax::error::Error::binding(BindingError { paths }));
        }

        type TR = crate::google::storage::control::v2::AnywhereCache;
        self.inner
            .execute(
                extensions,
                path,
                req.to_proto().map_err(Error::deser)?,
                options,
                &info::X_GOOG_API_CLIENT_HEADER,
                &x_goog_request_params,
            )
            .await
            .and_then(gaxi::grpc::to_gax_response::<TR, crate::model::AnywhereCache>)
    }

    async fn resume_anywhere_cache(
        &self,
        req: crate::model::ResumeAnywhereCacheRequest,
        options: gax::options::RequestOptions,
    ) -> Result<gax::response::Response<crate::model::AnywhereCache>> {
        use gaxi::prost::ToProto;
        let options = gax::options::internal::set_default_idempotency(options, true);
        let extensions = {
            let mut e = tonic::Extensions::new();
            e.insert(tonic::GrpcMethod::new(
                "google.storage.control.v2.StorageControl",
                "ResumeAnywhereCache",
            ));
            e
        };
        let path = http::uri::PathAndQuery::from_static(
            "/google.storage.control.v2.StorageControl/ResumeAnywhereCache",
        );
        let x_goog_request_params = {
            use gaxi::routing_parameter::Segment;
            gaxi::routing_parameter::format(&[None
                .or_else(|| {
                    gaxi::routing_parameter::value(
                        Some(&req).map(|m| &m.name).map(|s| s.as_str()),
                        &[],
                        &[
                            Segment::Literal("projects/"),
                            Segment::SingleWildcard,
                            Segment::Literal("/buckets/"),
                            Segment::SingleWildcard,
                        ],
                        &[Segment::MultiWildcard],
                    )
                })
                .map(|v| ("bucket", v))])
        };
        if x_goog_request_params.is_empty() {
            use gax::error::binding::BindingError;
            use gaxi::path_parameter::PathMismatchBuilder;
            use gaxi::routing_parameter::Segment;
            let mut paths = Vec::new();
            {
                let builder = PathMismatchBuilder::default();
                let builder = builder.maybe_add(
                    Some(&req).map(|m| &m.name).map(|s| s.as_str()),
                    &[
                        Segment::Literal("projects/"),
                        Segment::SingleWildcard,
                        Segment::Literal("/buckets/"),
                        Segment::SingleWildcard,
                        Segment::MultiWildcard,
                    ],
                    "name",
                    "projects/*/buckets/*/**",
                );
                paths.push(builder.build());
            }
            return Err(gax::error::Error::binding(BindingError { paths }));
        }

        type TR = crate::google::storage::control::v2::AnywhereCache;
        self.inner
            .execute(
                extensions,
                path,
                req.to_proto().map_err(Error::deser)?,
                options,
                &info::X_GOOG_API_CLIENT_HEADER,
                &x_goog_request_params,
            )
            .await
            .and_then(gaxi::grpc::to_gax_response::<TR, crate::model::AnywhereCache>)
    }

    async fn get_anywhere_cache(
        &self,
        req: crate::model::GetAnywhereCacheRequest,
        options: gax::options::RequestOptions,
    ) -> Result<gax::response::Response<crate::model::AnywhereCache>> {
        use gaxi::prost::ToProto;
        let options = gax::options::internal::set_default_idempotency(options, true);
        let extensions = {
            let mut e = tonic::Extensions::new();
            e.insert(tonic::GrpcMethod::new(
                "google.storage.control.v2.StorageControl",
                "GetAnywhereCache",
            ));
            e
        };
        let path = http::uri::PathAndQuery::from_static(
            "/google.storage.control.v2.StorageControl/GetAnywhereCache",
        );
        let x_goog_request_params = {
            use gaxi::routing_parameter::Segment;
            gaxi::routing_parameter::format(&[None
                .or_else(|| {
                    gaxi::routing_parameter::value(
                        Some(&req).map(|m| &m.name).map(|s| s.as_str()),
                        &[],
                        &[
                            Segment::Literal("projects/"),
                            Segment::SingleWildcard,
                            Segment::Literal("/buckets/"),
                            Segment::SingleWildcard,
                        ],
                        &[Segment::MultiWildcard],
                    )
                })
                .map(|v| ("bucket", v))])
        };
        if x_goog_request_params.is_empty() {
            use gax::error::binding::BindingError;
            use gaxi::path_parameter::PathMismatchBuilder;
            use gaxi::routing_parameter::Segment;
            let mut paths = Vec::new();
            {
                let builder = PathMismatchBuilder::default();
                let builder = builder.maybe_add(
                    Some(&req).map(|m| &m.name).map(|s| s.as_str()),
                    &[
                        Segment::Literal("projects/"),
                        Segment::SingleWildcard,
                        Segment::Literal("/buckets/"),
                        Segment::SingleWildcard,
                        Segment::MultiWildcard,
                    ],
                    "name",
                    "projects/*/buckets/*/**",
                );
                paths.push(builder.build());
            }
            return Err(gax::error::Error::binding(BindingError { paths }));
        }

        type TR = crate::google::storage::control::v2::AnywhereCache;
        self.inner
            .execute(
                extensions,
                path,
                req.to_proto().map_err(Error::deser)?,
                options,
                &info::X_GOOG_API_CLIENT_HEADER,
                &x_goog_request_params,
            )
            .await
            .and_then(gaxi::grpc::to_gax_response::<TR, crate::model::AnywhereCache>)
    }

    async fn list_anywhere_caches(
        &self,
        req: crate::model::ListAnywhereCachesRequest,
        options: gax::options::RequestOptions,
    ) -> Result<gax::response::Response<crate::model::ListAnywhereCachesResponse>> {
        use gaxi::prost::ToProto;
        let options = gax::options::internal::set_default_idempotency(options, true);
        let extensions = {
            let mut e = tonic::Extensions::new();
            e.insert(tonic::GrpcMethod::new(
                "google.storage.control.v2.StorageControl",
                "ListAnywhereCaches",
            ));
            e
        };
        let path = http::uri::PathAndQuery::from_static(
            "/google.storage.control.v2.StorageControl/ListAnywhereCaches",
        );
        let x_goog_request_params = {
            use gaxi::routing_parameter::Segment;
            gaxi::routing_parameter::format(&[None
                .or_else(|| {
                    gaxi::routing_parameter::value(
                        Some(&req).map(|m| &m.parent).map(|s| s.as_str()),
                        &[],
                        &[Segment::MultiWildcard],
                        &[],
                    )
                })
                .map(|v| ("bucket", v))])
        };
        if x_goog_request_params.is_empty() {
            use gax::error::binding::BindingError;
            use gaxi::path_parameter::PathMismatchBuilder;
            use gaxi::routing_parameter::Segment;
            let mut paths = Vec::new();
            {
                let builder = PathMismatchBuilder::default();
                let builder = builder.maybe_add(
                    Some(&req).map(|m| &m.parent).map(|s| s.as_str()),
                    &[Segment::MultiWildcard],
                    "parent",
                    "**",
                );
                paths.push(builder.build());
            }
            return Err(gax::error::Error::binding(BindingError { paths }));
        }

        type TR = crate::google::storage::control::v2::ListAnywhereCachesResponse;
        self.inner
            .execute(
                extensions,
                path,
                req.to_proto().map_err(Error::deser)?,
                options,
                &info::X_GOOG_API_CLIENT_HEADER,
                &x_goog_request_params,
            )
            .await
            .and_then(gaxi::grpc::to_gax_response::<TR, crate::model::ListAnywhereCachesResponse>)
    }

    async fn get_project_intelligence_config(
        &self,
        req: crate::model::GetProjectIntelligenceConfigRequest,
        options: gax::options::RequestOptions,
    ) -> Result<gax::response::Response<crate::model::IntelligenceConfig>> {
        use gaxi::prost::ToProto;
        let options = gax::options::internal::set_default_idempotency(options, true);
        let extensions = {
            let mut e = tonic::Extensions::new();
            e.insert(tonic::GrpcMethod::new(
                "google.storage.control.v2.StorageControl",
                "GetProjectIntelligenceConfig",
            ));
            e
        };
        let path = http::uri::PathAndQuery::from_static(
            "/google.storage.control.v2.StorageControl/GetProjectIntelligenceConfig",
        );
        let x_goog_request_params = [Some(&req)
            .map(|m| &m.name)
            .map(|s| s.as_str())
            .map(|v| format!("name={v}"))]
        .into_iter()
        .flatten()
        .fold(String::new(), |b, p| b + "&" + &p);

        type TR = crate::google::storage::control::v2::IntelligenceConfig;
        self.inner
            .execute(
                extensions,
                path,
                req.to_proto().map_err(Error::deser)?,
                options,
                &info::X_GOOG_API_CLIENT_HEADER,
                &x_goog_request_params,
            )
            .await
            .and_then(gaxi::grpc::to_gax_response::<TR, crate::model::IntelligenceConfig>)
    }

    async fn update_project_intelligence_config(
        &self,
        req: crate::model::UpdateProjectIntelligenceConfigRequest,
        options: gax::options::RequestOptions,
    ) -> Result<gax::response::Response<crate::model::IntelligenceConfig>> {
        use gaxi::prost::ToProto;
        let options = gax::options::internal::set_default_idempotency(options, false);
        let extensions = {
            let mut e = tonic::Extensions::new();
            e.insert(tonic::GrpcMethod::new(
                "google.storage.control.v2.StorageControl",
                "UpdateProjectIntelligenceConfig",
            ));
            e
        };
        let path = http::uri::PathAndQuery::from_static(
            "/google.storage.control.v2.StorageControl/UpdateProjectIntelligenceConfig",
        );
        let x_goog_request_params = [Some(&req)
            .and_then(|m| m.intelligence_config.as_ref())
            .map(|m| &m.name)
            .map(|s| s.as_str())
            .map(|v| format!("intelligence_config.name={v}"))]
        .into_iter()
        .flatten()
        .fold(String::new(), |b, p| b + "&" + &p);

        type TR = crate::google::storage::control::v2::IntelligenceConfig;
        self.inner
            .execute(
                extensions,
                path,
                req.to_proto().map_err(Error::deser)?,
                options,
                &info::X_GOOG_API_CLIENT_HEADER,
                &x_goog_request_params,
            )
            .await
            .and_then(gaxi::grpc::to_gax_response::<TR, crate::model::IntelligenceConfig>)
    }

    async fn get_folder_intelligence_config(
        &self,
        req: crate::model::GetFolderIntelligenceConfigRequest,
        options: gax::options::RequestOptions,
    ) -> Result<gax::response::Response<crate::model::IntelligenceConfig>> {
        use gaxi::prost::ToProto;
        let options = gax::options::internal::set_default_idempotency(options, true);
        let extensions = {
            let mut e = tonic::Extensions::new();
            e.insert(tonic::GrpcMethod::new(
                "google.storage.control.v2.StorageControl",
                "GetFolderIntelligenceConfig",
            ));
            e
        };
        let path = http::uri::PathAndQuery::from_static(
            "/google.storage.control.v2.StorageControl/GetFolderIntelligenceConfig",
        );
        let x_goog_request_params = [Some(&req)
            .map(|m| &m.name)
            .map(|s| s.as_str())
            .map(|v| format!("name={v}"))]
        .into_iter()
        .flatten()
        .fold(String::new(), |b, p| b + "&" + &p);

        type TR = crate::google::storage::control::v2::IntelligenceConfig;
        self.inner
            .execute(
                extensions,
                path,
                req.to_proto().map_err(Error::deser)?,
                options,
                &info::X_GOOG_API_CLIENT_HEADER,
                &x_goog_request_params,
            )
            .await
            .and_then(gaxi::grpc::to_gax_response::<TR, crate::model::IntelligenceConfig>)
    }

    async fn update_folder_intelligence_config(
        &self,
        req: crate::model::UpdateFolderIntelligenceConfigRequest,
        options: gax::options::RequestOptions,
    ) -> Result<gax::response::Response<crate::model::IntelligenceConfig>> {
        use gaxi::prost::ToProto;
        let options = gax::options::internal::set_default_idempotency(options, false);
        let extensions = {
            let mut e = tonic::Extensions::new();
            e.insert(tonic::GrpcMethod::new(
                "google.storage.control.v2.StorageControl",
                "UpdateFolderIntelligenceConfig",
            ));
            e
        };
        let path = http::uri::PathAndQuery::from_static(
            "/google.storage.control.v2.StorageControl/UpdateFolderIntelligenceConfig",
        );
        let x_goog_request_params = [Some(&req)
            .and_then(|m| m.intelligence_config.as_ref())
            .map(|m| &m.name)
            .map(|s| s.as_str())
            .map(|v| format!("intelligence_config.name={v}"))]
        .into_iter()
        .flatten()
        .fold(String::new(), |b, p| b + "&" + &p);

        type TR = crate::google::storage::control::v2::IntelligenceConfig;
        self.inner
            .execute(
                extensions,
                path,
                req.to_proto().map_err(Error::deser)?,
                options,
                &info::X_GOOG_API_CLIENT_HEADER,
                &x_goog_request_params,
            )
            .await
            .and_then(gaxi::grpc::to_gax_response::<TR, crate::model::IntelligenceConfig>)
    }

    async fn get_organization_intelligence_config(
        &self,
        req: crate::model::GetOrganizationIntelligenceConfigRequest,
        options: gax::options::RequestOptions,
    ) -> Result<gax::response::Response<crate::model::IntelligenceConfig>> {
        use gaxi::prost::ToProto;
        let options = gax::options::internal::set_default_idempotency(options, true);
        let extensions = {
            let mut e = tonic::Extensions::new();
            e.insert(tonic::GrpcMethod::new(
                "google.storage.control.v2.StorageControl",
                "GetOrganizationIntelligenceConfig",
            ));
            e
        };
        let path = http::uri::PathAndQuery::from_static(
            "/google.storage.control.v2.StorageControl/GetOrganizationIntelligenceConfig",
        );
        let x_goog_request_params = [Some(&req)
            .map(|m| &m.name)
            .map(|s| s.as_str())
            .map(|v| format!("name={v}"))]
        .into_iter()
        .flatten()
        .fold(String::new(), |b, p| b + "&" + &p);

        type TR = crate::google::storage::control::v2::IntelligenceConfig;
        self.inner
            .execute(
                extensions,
                path,
                req.to_proto().map_err(Error::deser)?,
                options,
                &info::X_GOOG_API_CLIENT_HEADER,
                &x_goog_request_params,
            )
            .await
            .and_then(gaxi::grpc::to_gax_response::<TR, crate::model::IntelligenceConfig>)
    }

    async fn update_organization_intelligence_config(
        &self,
        req: crate::model::UpdateOrganizationIntelligenceConfigRequest,
        options: gax::options::RequestOptions,
    ) -> Result<gax::response::Response<crate::model::IntelligenceConfig>> {
        use gaxi::prost::ToProto;
        let options = gax::options::internal::set_default_idempotency(options, false);
        let extensions = {
            let mut e = tonic::Extensions::new();
            e.insert(tonic::GrpcMethod::new(
                "google.storage.control.v2.StorageControl",
                "UpdateOrganizationIntelligenceConfig",
            ));
            e
        };
        let path = http::uri::PathAndQuery::from_static(
            "/google.storage.control.v2.StorageControl/UpdateOrganizationIntelligenceConfig",
        );
        let x_goog_request_params = [Some(&req)
            .and_then(|m| m.intelligence_config.as_ref())
            .map(|m| &m.name)
            .map(|s| s.as_str())
            .map(|v| format!("intelligence_config.name={v}"))]
        .into_iter()
        .flatten()
        .fold(String::new(), |b, p| b + "&" + &p);

        type TR = crate::google::storage::control::v2::IntelligenceConfig;
        self.inner
            .execute(
                extensions,
                path,
                req.to_proto().map_err(Error::deser)?,
                options,
                &info::X_GOOG_API_CLIENT_HEADER,
                &x_goog_request_params,
            )
            .await
            .and_then(gaxi::grpc::to_gax_response::<TR, crate::model::IntelligenceConfig>)
    }

    async fn get_iam_policy(
        &self,
        req: iam_v1::model::GetIamPolicyRequest,
        options: gax::options::RequestOptions,
    ) -> Result<gax::response::Response<iam_v1::model::Policy>> {
        use gaxi::prost::ToProto;
        let options = gax::options::internal::set_default_idempotency(options, false);
        let extensions = {
            let mut e = tonic::Extensions::new();
            e.insert(tonic::GrpcMethod::new(
                "google.storage.control.v2.StorageControl",
                "GetIamPolicy",
            ));
            e
        };
        let path = http::uri::PathAndQuery::from_static(
            "/google.storage.control.v2.StorageControl/GetIamPolicy",
        );
        let x_goog_request_params = {
            use gaxi::routing_parameter::Segment;
            gaxi::routing_parameter::format(&[None
                .or_else(|| {
                    gaxi::routing_parameter::value(
                        Some(&req).map(|m| &m.resource).map(|s| s.as_str()),
                        &[],
                        &[
                            Segment::Literal("projects/"),
                            Segment::SingleWildcard,
                            Segment::Literal("/buckets/"),
                            Segment::SingleWildcard,
                        ],
                        &[Segment::MultiWildcard],
                    )
                })
                .or_else(|| {
                    gaxi::routing_parameter::value(
                        Some(&req).map(|m| &m.resource).map(|s| s.as_str()),
                        &[],
                        &[Segment::MultiWildcard],
                        &[],
                    )
                })
                .map(|v| ("bucket", v))])
        };
        if x_goog_request_params.is_empty() {
            use gax::error::binding::BindingError;
            use gaxi::path_parameter::PathMismatchBuilder;
            use gaxi::routing_parameter::Segment;
            let mut paths = Vec::new();
            {
                let builder = PathMismatchBuilder::default();
                let builder = builder.maybe_add(
                    Some(&req).map(|m| &m.resource).map(|s| s.as_str()),
                    &[
                        Segment::Literal("projects/"),
                        Segment::SingleWildcard,
                        Segment::Literal("/buckets/"),
                        Segment::SingleWildcard,
                        Segment::MultiWildcard,
                    ],
                    "resource",
                    "projects/*/buckets/*/**",
                );
                paths.push(builder.build());
            }
            {
                let builder = PathMismatchBuilder::default();
                let builder = builder.maybe_add(
                    Some(&req).map(|m| &m.resource).map(|s| s.as_str()),
                    &[Segment::MultiWildcard],
                    "resource",
                    "**",
                );
                paths.push(builder.build());
            }
            return Err(gax::error::Error::binding(BindingError { paths }));
        }

        type TR = crate::google::iam::v1::Policy;
        self.inner
            .execute(
                extensions,
                path,
                req.to_proto().map_err(Error::deser)?,
                options,
                &info::X_GOOG_API_CLIENT_HEADER,
                &x_goog_request_params,
            )
            .await
            .and_then(gaxi::grpc::to_gax_response::<TR, iam_v1::model::Policy>)
    }

    async fn set_iam_policy(
        &self,
        req: iam_v1::model::SetIamPolicyRequest,
        options: gax::options::RequestOptions,
    ) -> Result<gax::response::Response<iam_v1::model::Policy>> {
        use gaxi::prost::ToProto;
        let options = gax::options::internal::set_default_idempotency(options, false);
        let extensions = {
            let mut e = tonic::Extensions::new();
            e.insert(tonic::GrpcMethod::new(
                "google.storage.control.v2.StorageControl",
                "SetIamPolicy",
            ));
            e
        };
        let path = http::uri::PathAndQuery::from_static(
            "/google.storage.control.v2.StorageControl/SetIamPolicy",
        );
        let x_goog_request_params = {
            use gaxi::routing_parameter::Segment;
            gaxi::routing_parameter::format(&[None
                .or_else(|| {
                    gaxi::routing_parameter::value(
                        Some(&req).map(|m| &m.resource).map(|s| s.as_str()),
                        &[],
                        &[
                            Segment::Literal("projects/"),
                            Segment::SingleWildcard,
                            Segment::Literal("/buckets/"),
                            Segment::SingleWildcard,
                        ],
                        &[Segment::MultiWildcard],
                    )
                })
                .or_else(|| {
                    gaxi::routing_parameter::value(
                        Some(&req).map(|m| &m.resource).map(|s| s.as_str()),
                        &[],
                        &[Segment::MultiWildcard],
                        &[],
                    )
                })
                .map(|v| ("bucket", v))])
        };
        if x_goog_request_params.is_empty() {
            use gax::error::binding::BindingError;
            use gaxi::path_parameter::PathMismatchBuilder;
            use gaxi::routing_parameter::Segment;
            let mut paths = Vec::new();
            {
                let builder = PathMismatchBuilder::default();
                let builder = builder.maybe_add(
                    Some(&req).map(|m| &m.resource).map(|s| s.as_str()),
                    &[
                        Segment::Literal("projects/"),
                        Segment::SingleWildcard,
                        Segment::Literal("/buckets/"),
                        Segment::SingleWildcard,
                        Segment::MultiWildcard,
                    ],
                    "resource",
                    "projects/*/buckets/*/**",
                );
                paths.push(builder.build());
            }
            {
                let builder = PathMismatchBuilder::default();
                let builder = builder.maybe_add(
                    Some(&req).map(|m| &m.resource).map(|s| s.as_str()),
                    &[Segment::MultiWildcard],
                    "resource",
                    "**",
                );
                paths.push(builder.build());
            }
            return Err(gax::error::Error::binding(BindingError { paths }));
        }

        type TR = crate::google::iam::v1::Policy;
        self.inner
            .execute(
                extensions,
                path,
                req.to_proto().map_err(Error::deser)?,
                options,
                &info::X_GOOG_API_CLIENT_HEADER,
                &x_goog_request_params,
            )
            .await
            .and_then(gaxi::grpc::to_gax_response::<TR, iam_v1::model::Policy>)
    }

    async fn test_iam_permissions(
        &self,
        req: iam_v1::model::TestIamPermissionsRequest,
        options: gax::options::RequestOptions,
    ) -> Result<gax::response::Response<iam_v1::model::TestIamPermissionsResponse>> {
        use gaxi::prost::ToProto;
        let options = gax::options::internal::set_default_idempotency(options, false);
        let extensions = {
            let mut e = tonic::Extensions::new();
            e.insert(tonic::GrpcMethod::new(
                "google.storage.control.v2.StorageControl",
                "TestIamPermissions",
            ));
            e
        };
        let path = http::uri::PathAndQuery::from_static(
            "/google.storage.control.v2.StorageControl/TestIamPermissions",
        );
        let x_goog_request_params = {
            use gaxi::routing_parameter::Segment;
            gaxi::routing_parameter::format(&[None
                .or_else(|| {
                    gaxi::routing_parameter::value(
                        Some(&req).map(|m| &m.resource).map(|s| s.as_str()),
                        &[],
                        &[
                            Segment::Literal("projects/"),
                            Segment::SingleWildcard,
                            Segment::Literal("/buckets/"),
                            Segment::SingleWildcard,
                        ],
                        &[
                            Segment::Literal("managedFolders"),
                            Segment::TrailingMultiWildcard,
                        ],
                    )
                })
                .or_else(|| {
                    gaxi::routing_parameter::value(
                        Some(&req).map(|m| &m.resource).map(|s| s.as_str()),
                        &[],
                        &[
                            Segment::Literal("projects/"),
                            Segment::SingleWildcard,
                            Segment::Literal("/buckets/"),
                            Segment::SingleWildcard,
                        ],
                        &[Segment::Literal("objects"), Segment::TrailingMultiWildcard],
                    )
                })
                .or_else(|| {
                    gaxi::routing_parameter::value(
                        Some(&req).map(|m| &m.resource).map(|s| s.as_str()),
                        &[],
                        &[Segment::MultiWildcard],
                        &[],
                    )
                })
                .map(|v| ("bucket", v))])
        };
        if x_goog_request_params.is_empty() {
            use gax::error::binding::BindingError;
            use gaxi::path_parameter::PathMismatchBuilder;
            use gaxi::routing_parameter::Segment;
            let mut paths = Vec::new();
            {
                let builder = PathMismatchBuilder::default();
                let builder = builder.maybe_add(
                    Some(&req).map(|m| &m.resource).map(|s| s.as_str()),
                    &[
                        Segment::Literal("projects/"),
                        Segment::SingleWildcard,
                        Segment::Literal("/buckets/"),
                        Segment::SingleWildcard,
                        Segment::Literal("managedFolders"),
                        Segment::TrailingMultiWildcard,
                    ],
                    "resource",
                    "projects/*/buckets/*/managedFolders/**",
                );
                paths.push(builder.build());
            }
            {
                let builder = PathMismatchBuilder::default();
                let builder = builder.maybe_add(
                    Some(&req).map(|m| &m.resource).map(|s| s.as_str()),
                    &[
                        Segment::Literal("projects/"),
                        Segment::SingleWildcard,
                        Segment::Literal("/buckets/"),
                        Segment::SingleWildcard,
                        Segment::Literal("objects"),
                        Segment::TrailingMultiWildcard,
                    ],
                    "resource",
                    "projects/*/buckets/*/objects/**",
                );
                paths.push(builder.build());
            }
            {
                let builder = PathMismatchBuilder::default();
                let builder = builder.maybe_add(
                    Some(&req).map(|m| &m.resource).map(|s| s.as_str()),
                    &[Segment::MultiWildcard],
                    "resource",
                    "**",
                );
                paths.push(builder.build());
            }
            return Err(gax::error::Error::binding(BindingError { paths }));
        }

        type TR = crate::google::iam::v1::TestIamPermissionsResponse;
        self.inner
            .execute(
                extensions,
                path,
                req.to_proto().map_err(Error::deser)?,
                options,
                &info::X_GOOG_API_CLIENT_HEADER,
                &x_goog_request_params,
            )
            .await
            .and_then(gaxi::grpc::to_gax_response::<TR, iam_v1::model::TestIamPermissionsResponse>)
    }

    async fn get_operation(
        &self,
        req: longrunning::model::GetOperationRequest,
        options: gax::options::RequestOptions,
    ) -> Result<gax::response::Response<longrunning::model::Operation>> {
        use gaxi::prost::ToProto;
        let options = gax::options::internal::set_default_idempotency(options, true);
        let extensions = {
            let mut e = tonic::Extensions::new();
            e.insert(tonic::GrpcMethod::new(
                "google.longrunning.Operations",
                "GetOperation",
            ));
            e
        };
        let path =
            http::uri::PathAndQuery::from_static("/google.longrunning.Operations/GetOperation");
        let x_goog_request_params = [Some(&req)
            .map(|m| &m.name)
            .map(|s| s.as_str())
            .map(|v| format!("name={v}"))]
        .into_iter()
        .flatten()
        .fold(String::new(), |b, p| b + "&" + &p);

        type TR = crate::google::longrunning::Operation;
        self.inner
            .execute(
                extensions,
                path,
                req.to_proto().map_err(Error::deser)?,
                options,
                &info::X_GOOG_API_CLIENT_HEADER,
                &x_goog_request_params,
            )
            .await
            .and_then(gaxi::grpc::to_gax_response::<TR, longrunning::model::Operation>)
    }

    fn get_polling_error_policy(
        &self,
        options: &gax::options::RequestOptions,
    ) -> std::sync::Arc<dyn gax::polling_error_policy::PollingErrorPolicy> {
        self.inner.get_polling_error_policy(options)
    }

    fn get_polling_backoff_policy(
        &self,
        options: &gax::options::RequestOptions,
    ) -> std::sync::Arc<dyn gax::polling_backoff_policy::PollingBackoffPolicy> {
        self.inner.get_polling_backoff_policy(options)
    }
}

use gaxi::prost::{ConvertError, FromProto, ToProto};
/// Convert from our `wkt::Any` to a `prost_types::Any`
///
/// The encoded types considered for conversion are either metadata or result
/// types for LROs in this service.
pub(crate) fn lro_any_to_prost(
    value: wkt::Any,
) -> std::result::Result<prost_types::Any, ConvertError> {
    match value.type_url().unwrap_or_default() {
        "" => Ok(prost_types::Any::default()),
        "type.googleapis.com/google.storage.control.v2.RenameFolderMetadata" => value
            .to_msg::<crate::model::RenameFolderMetadata>()
            .map_err(ConvertError::other)?
            .to_proto()
            .and_then(|prost_msg| {
                prost_types::Any::from_msg(&prost_msg).map_err(ConvertError::other)
            }),
        "type.googleapis.com/google.storage.control.v2.Folder" => value
            .to_msg::<crate::model::Folder>()
            .map_err(ConvertError::other)?
            .to_proto()
            .and_then(|prost_msg| {
                prost_types::Any::from_msg(&prost_msg).map_err(ConvertError::other)
            }),
        "type.googleapis.com/google.storage.control.v2.CreateAnywhereCacheMetadata" => value
            .to_msg::<crate::model::CreateAnywhereCacheMetadata>()
            .map_err(ConvertError::other)?
            .to_proto()
            .and_then(|prost_msg| {
                prost_types::Any::from_msg(&prost_msg).map_err(ConvertError::other)
            }),
        "type.googleapis.com/google.storage.control.v2.AnywhereCache" => value
            .to_msg::<crate::model::AnywhereCache>()
            .map_err(ConvertError::other)?
            .to_proto()
            .and_then(|prost_msg| {
                prost_types::Any::from_msg(&prost_msg).map_err(ConvertError::other)
            }),
        "type.googleapis.com/google.storage.control.v2.UpdateAnywhereCacheMetadata" => value
            .to_msg::<crate::model::UpdateAnywhereCacheMetadata>()
            .map_err(ConvertError::other)?
            .to_proto()
            .and_then(|prost_msg| {
                prost_types::Any::from_msg(&prost_msg).map_err(ConvertError::other)
            }),
        type_url => Err(ConvertError::UnexpectedTypeUrl(type_url.to_string())),
    }
}

/// Convert from a `prost_types::Any` to our `wkt::Any`
///
/// The encoded types considered for conversion are either metadata or result
/// types for LROs in this service.
pub(crate) fn lro_any_from_prost(
    value: prost_types::Any,
) -> std::result::Result<wkt::Any, ConvertError> {
    match value.type_url.as_str() {
        "" => Ok(wkt::Any::default()),
        "type.googleapis.com/google.storage.control.v2.RenameFolderMetadata" => value
            .to_msg::<crate::google::storage::control::v2::RenameFolderMetadata>()
            .map_err(ConvertError::other)?
            .cnv()
            .and_then(|our_msg| wkt::Any::from_msg(&our_msg).map_err(ConvertError::other)),
        "type.googleapis.com/google.storage.control.v2.Folder" => value
            .to_msg::<crate::google::storage::control::v2::Folder>()
            .map_err(ConvertError::other)?
            .cnv()
            .and_then(|our_msg| wkt::Any::from_msg(&our_msg).map_err(ConvertError::other)),
        "type.googleapis.com/google.storage.control.v2.CreateAnywhereCacheMetadata" => value
            .to_msg::<crate::google::storage::control::v2::CreateAnywhereCacheMetadata>()
            .map_err(ConvertError::other)?
            .cnv()
            .and_then(|our_msg| wkt::Any::from_msg(&our_msg).map_err(ConvertError::other)),
        "type.googleapis.com/google.storage.control.v2.AnywhereCache" => value
            .to_msg::<crate::google::storage::control::v2::AnywhereCache>()
            .map_err(ConvertError::other)?
            .cnv()
            .and_then(|our_msg| wkt::Any::from_msg(&our_msg).map_err(ConvertError::other)),
        "type.googleapis.com/google.storage.control.v2.UpdateAnywhereCacheMetadata" => value
            .to_msg::<crate::google::storage::control::v2::UpdateAnywhereCacheMetadata>()
            .map_err(ConvertError::other)?
            .cnv()
            .and_then(|our_msg| wkt::Any::from_msg(&our_msg).map_err(ConvertError::other)),
        type_url => Err(ConvertError::UnexpectedTypeUrl(type_url.to_string())),
    }
}
